//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.vere.orm.util;

import java.sql.ResultSet;
import java.util.Calendar;

public class CDataType {
    public static String INT = "int";
    public static String LONG = "long";
    public static String DOUBLE = "double";
    public static String FLOAT = "float";
    public static String STRING = "string";
    public static String CALENDAR = "calendar";
    public static String TEXT = "text";
    public static String MYSQL = "mysql";
    public static String MS_SQL = "mssql";
    public static String ORACLE = "oracle";
    public static String DB2 = "db2";

    public CDataType() {
    }

    public static Class getObjectDataType(Object obj) {
        String type = obj.toString().toLowerCase();
        if (type.contains(CALENDAR)) {
            return Calendar.class;
        } else if (type.contains(INT)) {
            return Integer.TYPE;
        } else if (type.contains(FLOAT)) {
            return Float.TYPE;
        } else if (type.contains(DOUBLE)) {
            return Double.TYPE;
        } else {
            return type.contains(LONG) ? Long.TYPE : String.class;
        }
    }

    public static boolean isDatabaseField(Object obj) {
        boolean isField = false;
        String type = obj.toString().toLowerCase();
        if (type.contains(CALENDAR)) {
            isField = true;
        } else if (type.contains(INT)) {
            isField = true;
        } else if (type.contains(FLOAT)) {
            isField = true;
        } else if (type.contains(DOUBLE)) {
            isField = true;
        } else if (type.contains(LONG)) {
            isField = true;
        } else if (type.contains(STRING)) {
            isField = true;
        }

        return isField;
    }

    public static Object getData(Class dataType, ResultSet rs, String columnName) {
        String type = dataType.toString().toLowerCase();

        try {
            if (type.contains(CALENDAR)) {
                return CDate.formatDateTime(rs.getString(columnName));
            } else if (type.contains(INT)) {
                return rs.getInt(columnName);
            } else if (type.contains(FLOAT)) {
                return rs.getFloat(columnName);
            } else if (type.contains(DOUBLE)) {
                return rs.getDouble(columnName);
            } else {
                return type.contains(LONG) ? rs.getLong(columnName) : rs.getString(columnName);
            }
        } catch (Exception var5) {
            var5.printStackTrace();
            return null;
        }
    }

    public static boolean isMySQL(String driverType) {
        return MYSQL.equalsIgnoreCase(driverType);
    }

    public static boolean isSQLServer(String driverType) {
        return MS_SQL.equalsIgnoreCase(driverType);
    }

    public static boolean isOracle(String driverType) {
        return ORACLE.equalsIgnoreCase(driverType);
    }

    public static boolean isDB2(String driverType) {
        return DB2.equalsIgnoreCase(driverType);
    }
}
